/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.vienthonga.product.action;

import com.vienthonga.hibernate.pojo.TProduct;
import com.vienthonga.product.logic.M_Detail;
import com.vienthonga.product.logic.ShowMobilephoneDetailLogic;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author DoanHa
 */
public class ShowProductTooltipAction extends Action {

    private static final Logger logger = Logger.getLogger(
            ShowProductTooltipAction.class.getName());
    private static final String SUCCESS = "success";

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        logger.log(Level.INFO, mapping.getPath());

        //lay tham so request P_ID
        String p_id = request.getParameter("P_ID");
        //String p_id = "PHTC0001";
        //truy van xuong database
        ShowMobilephoneDetailLogic logic = new ShowMobilephoneDetailLogic();
        TProduct product = logic.getMobilephoneDetail(p_id);

        M_Detail detail = logic.getMDetailInfo(product);
        //dua du lieu vao request va gui den trang ket qua

        request.setAttribute("productDetails", detail);

        return mapping.findForward(SUCCESS);
    }
}
